﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Billing.DataObjects;

namespace Billing.Transactions
{
    public partial class BBTransfersForm : Billing.WindowsBase.BaseList
    {
        public BBTransfersForm()
        {
            InitializeComponent();
        }
        BillingDataContext mBillingDataContext;
        public BillingDataContext BillingDataContext
        {
            get
            {
                if (mBillingDataContext == null)
                    mBillingDataContext = new BillingDataContext();
                return mBillingDataContext;
            }
            set { mBillingDataContext = value; }
        }
        protected override void onDataLoad()
        {
            base.onDataLoad();
            this.bsElement.DataSource = this.BillingDataContext.HeadersLinesSelect(this.dtFrom.DateTime, this.dtTo.DateTime,5);

        }
        protected override void onElementInitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            base.onElementInitializeLayout(sender, e);
            this.ElementNameID = "ID";
            e.Layout.Bands[0].Columns["HeaderTypeID"].Hidden = true;
            e.Layout.Bands[0].Columns["HeaderStatusID"].Hidden = true;
            e.Layout.Bands[0].Columns["LineID"].Hidden = true;
            e.Layout.Bands[0].Columns["AccountID"].Hidden = true;
            e.Layout.Bands[0].Columns["TaxName"].Hidden = true;
            e.Layout.Bands[0].Columns["PaymentPointName"].Hidden = true;
            e.Layout.Bands[0].Columns["HeaderTypeName"].Hidden = true;
            e.Layout.Bands[0].Columns["HeaderStatusName"].Hidden = true;

            e.Layout.Bands[0].Columns["ID"].Header.VisiblePosition = 0;
            e.Layout.Bands[0].Columns["ID"].Width = 60;
            e.Layout.Bands[0].Columns["DocumentDate"].Header.VisiblePosition = 1;
            e.Layout.Bands[0].Columns["DocumentDate"].Width = 70;
            e.Layout.Bands[0].Columns["DocumentDate"].Header.Caption = "თარიღი";
            e.Layout.Bands[0].Columns["DocumentDate"].Format = "dd.MM.yyyy";
            e.Layout.Bands[0].Columns["Description"].Header.VisiblePosition = 2;
            e.Layout.Bands[0].Columns["Description"].Width = 110;
            e.Layout.Bands[0].Columns["Description"].Header.Caption = "აღწერა";
            e.Layout.Bands[0].Columns["Number"].Header.VisiblePosition = 3;
            e.Layout.Bands[0].Columns["Number"].Width = 60;
            e.Layout.Bands[0].Columns["Number"].Header.Caption = "ნომერი";
            e.Layout.Bands[0].Columns["ItemName"].Header.VisiblePosition = 4;
            e.Layout.Bands[0].Columns["ItemName"].Width = 110;
            e.Layout.Bands[0].Columns["ItemName"].Header.Caption = "სერვისი";
            e.Layout.Bands[0].Columns["Amount"].Header.VisiblePosition = 5;
            e.Layout.Bands[0].Columns["Amount"].Width = 50;
            e.Layout.Bands[0].Columns["Amount"].Header.Caption = "თანხა";
            e.Layout.Bands[0].Columns["Amount"].Format = "#,##0.00";
            e.Layout.Bands[0].Columns["ClientID"].Header.VisiblePosition = 7;
            e.Layout.Bands[0].Columns["ClientID"].Width = 70;
            e.Layout.Bands[0].Columns["ClientID"].Header.Caption = "კლიენტის #";
            e.Layout.Bands[0].Columns["ClientName"].Header.VisiblePosition = 8;
            e.Layout.Bands[0].Columns["ClientName"].Width = 130;
            e.Layout.Bands[0].Columns["ClientName"].Header.Caption = "კლიენტი";
            e.Layout.Bands[0].Columns["ModifiedDate"].Header.VisiblePosition = 9;
            e.Layout.Bands[0].Columns["ModifiedDate"].Width = 115;
            e.Layout.Bands[0].Columns["ModifiedDate"].Header.Caption = "შეიცვალა";
            e.Layout.Bands[0].Columns["ModifiedDate"].Format = "dd.MM.yyyy hh:mm:ss";
            e.Layout.Bands[0].Columns["CreatedDate"].Header.VisiblePosition = 10;
            e.Layout.Bands[0].Columns["CreatedDate"].Width = 115;
            e.Layout.Bands[0].Columns["CreatedDate"].Header.Caption = "შეიქმნა";
            e.Layout.Bands[0].Columns["CreatedDate"].Format = "dd.MM.yyyy hh:mm:ss";
        }

        protected override void onEditorOpen(Billing.WindowsBase.eOpenMode OpenMode)
        {
            base.onEditorOpen(OpenMode);
            Transactions.BegineBalanceMoveForm frm = new BegineBalanceMoveForm();
            switch (OpenMode)
            {
                case Billing.WindowsBase.eOpenMode.New:
                    {
                        frm.AddNewHeader();
                        frm.ShowDialog();
                    }
                    break;
                case Billing.WindowsBase.eOpenMode.Edit:
                    {
                        throw new NotImplementedException();
                    }
                    break;
                case Billing.WindowsBase.eOpenMode.CheckInfo:
                    break;
                default:
                    break;
            }
        }
    }
}
